package com.ruoyi.controller;

import com.ruoyi.pojo.Balance;
import com.ruoyi.pojo.Goods;
//import com.ruoyi.service.impl.BalanceServiceImpl;
import com.ruoyi.service.impl.BalanceServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/provider")
public class ProviderController {
    @Value("${server.port}")
    private String post;
    @Value("${spring.application.name}")
    private String name;
    @Resource
    private BalanceServiceImpl balanceService;


    @GetMapping("/getpost")
    public String getPost(){
        return "当前端口："+post;
    }

    @GetMapping("/getname")
    public String getName(){
        return "当前服务名："+name;
    }

    /**
     * 获取所有
     * @return
     */
    @GetMapping("/getList")
    public Map<String, List<Balance>> getList(){
        Map<String, List<Balance>> map = new HashMap<>(2);
//        List<Balance> list = balanceService.getList();
//        log.info("我是自定义语句查询");
//        List<Balance> list1 = balanceService.list();
//        log.info("我是工具查询");
//        map.put("list",list);
//        map.put("list1",list1);
        return map;
    }

    @GetMapping("/update")
    public String update(){
        Balance balance = new Balance(1, 1, new BigDecimal(100), new BigDecimal(1));

        balanceService.updateBalance(balance);
        return "成功";
    }
}
